<?php

class requestmodule_request {
	function respone_form($object, $request) {
		if (!defined('SYS_FORMS')) require_once(BASE.'subsystems/forms.php');
		exponent_forms_initialize();

		$form = new form();
		if (!isset($object->id)) {
			$object->content = '';
		} else {
			$form->meta('id',$object->id);
		}
		//$config->remove_body_html=1;
		$form->register('content','Trả lời yêu cầu',new texteditorcontrol($object->content,3,60,true));
		$form->register('submit','',new buttongroupcontrol('Save'));
		return $form;
	}

	/**
	* This function save the public submit request
	* 
	* @param mixed $values
	* @param mixed $object
	* @author: trungdt
	*/
	function publicrequest_save($values,$object) {
		global $db;
		$lang = exponent_lang_loadFile('datatypes/rsrequest_item.php');
		
		$object->fullname=_ab_safe_html_string($values['fullname']);
		$object->phone=_ab_safe_html_string($values['phone']);
		$object->email=_ab_safe_html_string($values['email']);
		$object->content=strip_tags(_ab_safe_html_string($values['other_comment']));
		$object->request_date=aboid_getCurrentTime();
		$object->cat_id=$values['cat_id'];
		
		$object->user_id=-1;
		if (exponent_users_isLoggedIn())
		{
			global $user;
			$object->user_id=$user->id;
		}
		
		$object->from_date=strtotime($values['from_date']." ".$values['from_time']);
		$object->time_length=intval($values['time_length']);
		
		if (!isset($object->id))
		{
			if (exponent_users_isLoggedIn())
			{
				$object->approve=2;
				$object->approve_date=aboid_getCurrentTime();
				$object->not_approve_reason="Auto Approve";
				$object->approve_name="System";
			}
			else
				$object->approve=0;
		}
		else
			$object->approve=intval($values['approve']);
		
		$object->event_id=-1;
		
		return $object;
	}
}

?>